package com.xuecheng.content.convert;

import com.xuecheng.api.content.model.CourseBaseDTO;
import com.xuecheng.api.content.model.TeachplanDTO;
import com.xuecheng.api.content.model.TeachplanVO;
import com.xuecheng.content.entity.CourseBase;
import com.xuecheng.content.entity.Teachplan;
import com.xuecheng.content.entity.exd.TeachplanNode;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * <h4>xuecheng</h4>
 * <p>MapStruct类与类的属性转换工具使用</p>
 *
 * @author : by wujianming
 * @date : 2021-12-08 21:19
 **/
@Mapper //mapStruct提供的注解
public interface TeachplanConvert {
    //固定的值.后面参数为本类的字节码对象
    TeachplanConvert INSTANCE = Mappers.getMapper(TeachplanConvert.class);

    // 将courseBase转为CourseBaseDTO数据
    //如果两个类属性有不相同的名字.需要用source指定被转换类的属性
    //target指定转换类的属性
    @Mapping(source = "id", target = "courseBaseId")
//    @Mapping(source = "id",target = "courseBaseId")
    CourseBaseDTO entity2dto(CourseBase courseBase);

    @Mapping(source = "id", target = "teachPlanId")
    TeachplanDTO note2DTO(TeachplanNode teachplanNode);

    @Mapping(source = "id", target = "teachPlanId")
    TeachplanDTO po2DTO(Teachplan teachplan);

    @Mapping(source = "teachPlanId", target = "id")
    Teachplan dto2Po(TeachplanDTO teachplanDTO);


    TeachplanDTO vo2dto(TeachplanVO teachplanVO);

}
